package com.zhny.aiot.led.four.screen.plugin.factory.imp;

import com.zhny.aiot.led.four.screen.plugin.config.LedConfig;
import com.zhny.aiot.led.four.screen.plugin.factory.AbstractCmdFactory;
import com.zhny.aiot.led.four.screen.plugin.factory.ILedCmdFactory;
import com.zhny.aiot.led.four.screen.plugin.model.LedCommand;

import java.io.UnsupportedEncodingException;

public class LedCloseCmdFactoryImpl extends AbstractCmdFactory {
    public LedCloseCmdFactoryImpl(LedConfig config, ILedCmdFactory factory) {
        super(config, factory);
    }

    @Override
    protected LedCommand onEncode(Object param) {
        return new LedCommand(config,getCmd(),null);
    }

    @Override
    protected Class supportCmdParam() {
        return null;
    }

    @Override
    protected String cmdMethodName() {
        return "close";
    }

    @Override
    public int getCmd() {
        return 0x22;
    }

    @Override
    public LedCommand handler(String method, String json) throws UnsupportedEncodingException {
        if(method.equals(cmdMethodName())){
            return onEncode(null);
        }else{
            return next(method, json);
        }
    }
}
